package com.cdvtc.forum_system.util;

import java.sql.*;

public class DBUtil {
    private static Connection connection = null;
    public static Connection getConnection() {
        if(connection == null){
            try {
                Class.forName("com.mysql.cj.jdbc.Driver");
                connection=DriverManager.getConnection("jdbc:mysql://localhost:3306/forum_system?allowPublicKeyRetrieval=true&useSSL=false&serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=UTF-8","root","123456");
                System.out.print("connected");
            } catch (ClassNotFoundException | SQLException e) {
                e.printStackTrace();
            }
        }
        return connection;
    }

    public static void main(String[] args) {
        System.out.println(DBUtil.getConnection());
    }

    public static void release(ResultSet rs, PreparedStatement pst, Connection con) {

    }
}
